/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spring.app.genpostagelabel;

/**
 *
 * @author ashwani
 */
public class Item implements ItemConstants {

    private String itemName;
    private String itemNo;
    private String itemCode;

    public Item() {
    }

    public Item(String no, String name, String code) {
        itemName = name;
        itemNo = no;
        itemCode = code;
    }

    //abstract boolean oneStampRequired();
    public static String getItemCode(String itemNo, String itemName) {
        String itemCode = "NotFOund";
        if (itemNo == null || itemNo.equals("")) {
            System.out.println("Item No is empty");
            return itemCode;
        }
        if (itemName == null || itemName.equals("")) {
            System.out.println("Item Name is empty");
            return itemCode;
        }
        
        
        Item item = GenPostageLabel.itemMap.get(itemNo);
        if (item != null) {
            itemCode =  item.itemCode;
        } else {
            for (Item i : GenPostageLabel.items) {
                if(i.itemName.equalsIgnoreCase(itemName)){
                    itemCode = i.itemCode;
                    break;
                }
            }
        }

//        if (ACT_1_item_No_FM.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_FM;
//        } else if (ACT_1_item_No_2X_MUB_W.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_2X_MUB_W;
//        } else if (ACT_1_item_No_DK.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_DK;
//        } else if (ACT_1_item_No_ORANGE_USB_EXTN.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_ORANGE_USB_EXTN;
//        } else if (ACT_1_item_No_RLC.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_RLC;
//        } else if (ACT_1_item_No_BLK_USB_EXTN.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_BLK_USB_EXTN;
//        } else if (ACT_1_item_No_3M_LC.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_3M_LC;
//        } else if (ACT_1_item_No_MUB_W.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUB_W;
//        } else if (ACT_1_item_No_3_in_1_1.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_3_in_1_1;
//        } else if (ACT_1_item_No_CR.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_CR;
////        } else if (ACT_1_item_No_M_USB_W.equals(itemNo)) {
////            itemCode = ACT_1_item_Code_M_USB_W;
//        } else if (ACT_1_item_No_RLC_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_RLC_2;
//        } else if (ACT_1_item_No_5XMUB_W.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_5XMUB_W;
//        } else if (ACT_1_item_No_3M_LC_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_3M_LC_2;
//        } else if (ACT_1_item_No_3M_MUB_B.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_3M_MUB_B;
//        } else if (ACT_1_item_No_LC.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_LC;
//        } else if (ACT_1_item_No_S5_MUB_1M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_S5_MUB_1M;
//        } else if (ACT_1_item_No_LC_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_LC_2;
//        } else if (ACT_1_item_No_MUSB_B_1M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_B_1M;
//        } else if (ACT_1_item_No_MUSB_B_2M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_B_2M;
//        } else if (ACT_1_item_No_MUSB_B_3M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_B_3M;
//        } else if (ACT_1_item_No_MUSB_W_1M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_W_1M;
//        } else if (ACT_1_item_No_MUSB_W_2M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_W_2M;
//        } else if (ACT_1_item_No_MUSB_W_3M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_W_3M;
//        } else if (ACT_1_item_No_CR_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_CR_2;
//        } else if (ACT_1_item_No_LC_3M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_LC_3M;
//        } else if (ACT_1_item_No_MUB_W_3M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUB_W_3M;
//        }  else if (ACT_1_item_No_MUSB_W_1M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_W_1M_2;
//        } else if (ACT_1_item_No_MUSB_W_2M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_W_2M_2;
//        } else if (ACT_1_item_No_MUSB_W_3M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_W_3M_2;
//        } else if (ACT_1_item_No_MUSB_B_1M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_B_1M_2;
//        } else if (ACT_1_item_No_MUSB_B_2M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_B_2M_2;
//        } else if (ACT_1_item_No_MUSB_B_3M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_B_3M_2;
//        } } else if (ACT_1_item_No_SP_S2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_SP_S2;
//        }} else if (ACT_1_item_No_LC_3M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_LC_3M;
//        } else if (ACT_1_item_No_MUB_W_3M.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUB_W_3M;
//        }  else if (ACT_1_item_No_MUSB_W_1M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_W_1M_2;
//        } else if (ACT_1_item_No_MUSB_W_2M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_W_2M_2;
//        } else if (ACT_1_item_No_MUSB_W_3M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_W_3M_2;
//        } else if (ACT_1_item_No_MUSB_B_1M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_B_1M_2;
//        } else if (ACT_1_item_No_MUSB_B_2M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_B_2M_2;
//        } else if (ACT_1_item_No_MUSB_B_3M_2.equals(itemNo)) {
//            itemCode = ACT_1_item_Code_MUSB_B_3M_2;
//        }

//        if (itemCode == null || itemCode.equals("") || itemCode.equalsIgnoreCase("NotFound")) {
//            itemCode = getItemCodeByName(itemName);
//        }
//        System.out.println("ItemCode = <" + itemCode + ">");



        return itemCode;
    }

    public static String getItemCodeByName(String itemName) {
        String itemCode = "NotFound";


        if (ACT_1_item_Name_FM.equals(itemName)) {
            itemCode = ACT_1_item_Code_FM;
        } else if (ACT_1_item_Name_2X_MUB_W.equals(itemName)) {
            itemCode = ACT_1_item_Code_2X_MUB_W;
        } else if (ACT_1_item_Name_DK.equals(itemName)) {
            itemCode = ACT_1_item_Code_DK;
        } else if (ACT_1_item_Name_ORANGE_USB_EXTN.equals(itemName)) {
            itemCode = ACT_1_item_Code_ORANGE_USB_EXTN;
        } else if (ACT_1_item_Name_RLC.equals(itemName)) {
            itemCode = ACT_1_item_Code_RLC;
        } else if (ACT_1_item_Name_BLK_USB_EXTN.equals(itemName)) {
            itemCode = ACT_1_item_Code_BLK_USB_EXTN;
        } else if (ACT_1_item_Name_3M_LC.equals(itemName)) {
            itemCode = ACT_1_item_Code_3M_LC;
        } else if (ACT_1_item_Name_MUB_W.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUB_W;
        } else if (ACT_1_item_Name_3_in_1_1.equals(itemName)) {
            itemCode = ACT_1_item_Code_3_in_1_1;
        } else if (ACT_1_item_Name_CR.equals(itemName)) {
            itemCode = ACT_1_item_Code_CR;
//        } else if (ACT_1_item_Name_M_USB_W.equals(itemName)) {
//            itemCode = ACT_1_item_Code_M_USB_W;
        } else if (ACT_1_item_Name_RLC_2.equals(itemName)) {
            itemCode = ACT_1_item_Code_RLC_2;
        } else if (ACT_1_item_Name_5XMUB_W.equals(itemName)) {
            itemCode = ACT_1_item_Code_5XMUB_W;
        } else if (ACT_1_item_Name_3M_LC_2.equals(itemName)) {
            itemCode = ACT_1_item_Code_3M_LC_2;
        } else if (ACT_1_item_Name_3M_MUB_B.equals(itemName)) {
            itemCode = ACT_1_item_Code_3M_MUB_B;
        } else if (ACT_1_item_Name_LC.equals(itemName)) {
            itemCode = ACT_1_item_Code_LC;
        } else if (ACT_1_item_Name_S5_MUB_1M.equals(itemName)) {
            itemCode = ACT_1_item_Code_S5_MUB_1M;
        } else if (ACT_1_item_Name_LC_2.equals(itemName)) {
            itemCode = ACT_1_item_Code_LC_2;
        } else if (ACT_1_item_Name_MUSB_B_1M.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_B_1M;
        } else if (ACT_1_item_Name_MUSB_B_2M.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_B_2M;
        } else if (ACT_1_item_Name_MUSB_B_3M.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_B_3M;
        } else if (ACT_1_item_Name_MUSB_W_1M.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_W_1M;
        } else if (ACT_1_item_Name_MUSB_W_2M.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_W_2M;
        } else if (ACT_1_item_Name_MUSB_W_3M.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_W_3M;
        } else if (ACT_1_item_Name_CR_2.equals(itemName)) {
            itemCode = ACT_1_item_Code_CR_2;
        } else if (ACT_1_item_Name_LC_3M.equals(itemName)) {
            itemCode = ACT_1_item_Code_LC_3M;
        } else if (ACT_1_item_Name_MUB_W_3M.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUB_W_3M;
        } else if (ACT_1_item_Name_MUSB_W_1M_2.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_W_1M_2;
        } else if (ACT_1_item_Name_MUSB_W_2M_2.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_W_2M_2;
        } else if (ACT_1_item_Name_MUSB_W_3M_2.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_W_3M_2;
        } else if (ACT_1_item_Name_MUSB_B_1M_2.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_B_1M_2;
        } else if (ACT_1_item_Name_MUSB_B_2M_2.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_B_2M_2;
        } else if (ACT_1_item_Name_MUSB_B_3M_2.equals(itemName)) {
            itemCode = ACT_1_item_Code_MUSB_B_3M_2;
        }

        return itemCode;

    }
}
